package game_logic.util;

public class Vec2 {
    public int x;
    public int y;

    public Vec2(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public Vec2() {
        this(0, 0);
    }

    public Vec2 add(Vec2 other) {
        this.x += other.x;
        this.y += other.y;
        return this;
    }

    static public Vec2 add(Vec2 l, Vec2 r) {
        return new Vec2(l.x + r.x, l.y + r.y);
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) return false;
        if (this == obj) return true;
        Vec2 o = (Vec2) obj;
        return this.x == o.x && this.y == o.y;
    }

    @Override
    public int hashCode() {
        return this.x + this.y;
    }

    @Override
    public String toString() {
        return String.format("<%s, %s>", x, y);
    }
}
